<template>
  <div>
    <div class="echarts echarts_mar">
      <div class="echarts_title">客户兴趣占比</div>
      <div class="echarts_pie"></div>
    </div>
    <!-- 进十五日客户活跃度 -->
    <div class="echarts echarts_mar">
      <div class="echarts_title">近十五日客户活跃度</div>
      <div class="echarts_line"></div>
    </div>
    <!-- 进十五日客户活跃度 -->
    <!-- <div class="echarts echarts_mar">
            <div class="echarts_title">近十五日客户互动</div>
            <div class="echarts_bar"></div>
        </div> -->
    <div class="echarts_bottom">
      <div class="echarts_title">近十五日客户点击量</div>
      <div class="echarts_bottom_div" v-for="(item,index) in AIdatas.clientInteractionList" :key="index">
        <h6 style=" font-weight: 400">{{item.name}}</h6>
        <span :style="{width:`${item.rate*60/100}vw`}"></span>
        <li>{{item.rate}}%</li>
      </div>
    </div>
  </div>
</template>

<script>
let echarts = require("../../../node_modules/echarts/lib/echarts");
//引入折线图
require("../../../node_modules/echarts/lib/chart/line");
//引入环形图
require("../../../node_modules/echarts/lib/chart/pie");
//引入柱状图
require("../../../node_modules/echarts/lib/chart/bar");
//引入legent
require("../../../node_modules/echarts/lib/component/legendScroll");
export default {
  props: ["AIdatas"],
  data() {
    return {
      
      barDatas: []
    };
  },
  mounted() {
    // console.log(this.AIdatas)
    var echarts_line = this.echarts_line();
    var echarts_pie = this.echarts_pie();
    //重绘，窗口大小改动时
    window.onresize = function temp() {
      echarts_line.resize();
      echarts_pie().resize();
    };
  },
  methods: {
    //客户兴趣暂避bar
    echarts_pie() {
      let that = this;
      // 基于准备好的dom，初始化echarts实例
      let myChart = echarts.init(
        document.getElementsByClassName("echarts_pie")[0]
      );
      // 绘制图表
      let option = {
        color: ["#c23531", "#2f4554", "#91c7ae"],
        legend: {
          bottom: 30,
          itemGap: 20,
          data: that.AIdatas.interestName
        },
        series: [
          {
            name: "访问来源",
            type: "pie",
            center: ["50%", "30%"],
            radius: ["30%", "40%"],
            avoidLabelOverlap: false,
            label: {
              normal: {
                show: true,
                position: "outside"
              }
            },
            labelLine: {
              normal: {
                show: true
              }
            },
            data: that.AIdatas.interestList
          }
        ]
      };
      myChart.setOption(option);
    },
    //进十五日客户活跃度
    echarts_line() {
      let that = this;
      // 基于准备好的dom，初始化echarts实例
      let myChart = echarts.init(
        document.getElementsByClassName("echarts_line")[0]
      );
      // 绘制图表
      let option = {
        color: ["#f6acac", "#d48265", "#c23531"],
        xAxis: {
          gridIndex: "0",
          type: "category",
          boundaryGap: false,
          data: that.AIdatas.activityName
        },
        yAxis: [
          {
            type: "value",
            position: "left"
          }
        ],
        grid: {
          top: "5%",
          left: "5%",
          right: "5%",
          bottom: "10%",
          containLabel: true
        },
        series: [
          {
            data: that.AIdatas.activityList,
            type: "line",
            areaStyle: { normal: {} }
            // label: {
            //   normal: {
            //     show: true,
            //     position: "top"
            //   }
            // }
          }
        ]
      };
      myChart.setOption(option);
    }
  }
};
</script>
<style scoped>
.echarts_mar {
  margin-top: 20px;
}
.echarts {
  width: 100vw;
  min-height: 460px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.echarts_title {
  height: 160px;
  display: flex;
  align-items: center;
  font-size: 32px;
}
.echarts_funnel {
  width: 100vw;
  height: 300px;
}
.echarts_line {
  width: 100vw;
  height: 600px;
}
.echarts_tabs {
  width: 60%;
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.echarts_tabs ul {
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid #e9e9e9;
}
.echarts_tabs .sel {
  border-color: #e93636;
  color: #e93636;
}
.echarts_pie {
  width: 100vw;
  height: 500px;
}
.echarts_bar {
  width: 100vw;
  height: 500px;
}

.echarts_bottom {
  width: 100vw;
  min-height: 100px;
  background: #fff;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.echarts_bottom_div {
  width: 90vw;
  height: 60px;
  display: flex;
  align-items: center;
}
.echarts_bottom_div h6 {
  width: 22vw;
}
.echarts_bottom_div span {
  width: 70vw;
  height: 30px;
  background: #f7adad;
  border-radius: 20px;
  margin-right: 20px;
}
</style>
